package cn.song.docflow.common;

import lombok.Getter;

/**
 * 自定义异常
 *
 * @author SongRenShuo
 * @date 2023/05/20
 */
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    @Getter
    private final Integer code;

    /**
     * 错误消息
     */
    private final String msg;

    /**
     * 构造函数
     *
     * @param msg 错误消息
     */
    public CustomException(String msg) {
        this(msg, 500);
    }

    /**
     * 构造函数
     *
     * @param msg 错误消息
     * @param code    错误码
     */
    public CustomException(String msg, Integer code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    /**
     * 获取错误消息
     *
     * @return 错误消息
     */
    public String getMsg() {
        return msg;
    }
}
